<h2>Image Upload Module v0.4</h2>
<strong>Created by:</strong> Cent (<a href="http://www.cando-ent.com/">www.cando-ent.com</a>)<br/>
<strong>Created on:</strong> 2007/04/12<br/>
<strong>Requires</strong> <a href="<?php echo my_base_url_.my_pligg_base; ?>/admin_config.php?page=ExtraFields">Extra Fields</a> Enabled, Thickbox Module (used if installed and the module is activated. Settings can be changed in image_upload_settings.php)
		
<h3>Description</h3>
This module allow users to upload a photo with their submission.  All images are stored locally on the
server and are named the same as the entry id (ie. 1024.img).  Currently the module does not keep the
original file name in the database.  Images can be uploaded in JPG, GIF, PNG and WBMP.  All images are resized upon upload to the dimensions set by the site admin and GIF, PNG and WBMP images are automatically converted to JPG format.  After the new image is sized and saved, the original image the user uploaded is deleted.<br/>






<h3>Installation</h3>

<ol>

<li>Edit <b>/libs/extra_fields.php</b><br/><br/>
Enable the extra field that will hold the image file name by <b>changing</b>:<br/><br/>
<i>Define('Enable_Extra_Field_1', false)</i><br/>
-to-<br/>
<i>Define('Enable_Extra_Field_1', true)</i><br/>

<br/>

<b>Change:</b><br/><br/>
<i>Define('Field_1_Title', '');</i><br/>
-to-<br/>
<i>Define('Field_1_Title', 'Select a photo:');</i><br/>

<br/>

<b>Change:</b><br/><br/>
<i>Define('Field_1_Instructions', '');</i><br/>
-to-<br/>
<i>Define('Field_1_Instructions', 'Select a JPG, GIF, PNG or WBMP photo from your computer.');</i></li>

<br/>

<li>Edit <b>/templates/(your template)/submit_extra_fields.tpl</b><br/><br/>
Look for the extra field you enabled.  If you are using link_field1 (as with the example above),<br/><br/>

<b>Change:</b><br/><br/>
<i>&lt;input type="text" name="link_field1" id="link_field1" value="{$submit_link_field1}" size="60" class="form-full" /&gt;</i><br/>
-to-<br/>
<i>&lt;input type="file" name="link_field1" id="link_field1" size="20" class="form-full" /&gt;</i><br/><br/>

This will allow for file uploads.</li>

<br/>

<li>Edit <b>/templates/(your template)/submit_step_2.tpl</b><br/><br/>
<b>Change:</b><br/><br/>
<i>&lt;form action="submit.php" method="post" name="thisform" id="thisform"&gt;</i><br/>
-to-<br/>
<i>&lt;form action="submit.php" method="post" name="thisform" id="thisform" enctype="multipart/form-data"&gt;</i><br/><br/>

Required for file uploads.</li>

<br/>

<li>Edit <b>/templates/(your template)/submit_step_3.tpl</b><br/><br/>
<b>Look for:</b><br/><br/>
<em>$linkres->store();<br/>
tags_insert_string($linkres->id, $dblang, $linkres->tags); <br/>
</em><br/>
And add the code below <b>between</b> those 2 lines: <br/><br/>
<em>
// START:  Image Upload Module<br/>
check_actions('image_upload_process');<br/>
// END:  Image Upload Module<br/>
</em><br/>


<li>Edit <b>/templates/(your template)/link_summary.tpl</b><br/><br/>
<b>Look For:</b><br/><br/>
<em>
	&lt;div class="news-submitted"&gt;
</em>
<br/><br/>
Add add the code below <b>above</b> that line<br/><br/>

<em> &lt;div style="float:right;"&gt;	{php}	check_actions('image_upload_preview');	{/php} &lt;/div&gt; </em>

<br/><br/>

 This code triggers the Image Upload module to show the image.  Ideally you can place the above code anywhere within <b>link_summary.tpl</b> where you want to image to show up at.<br/><br/>
 
 Also, be sure to comment out or remove the following <b>two</b> lines:<br/><br/>
 
 <em>{if $Enable_Extra_Field_1 eq 1}{if $link_field1 neq ""}&lt;br/&gt;&lt;b&gt;{$Field_1_Title}:&lt;/b&gt; {$link_field1}{/if}{/if}&lt;br/&gt;&lt;br/&gt;</em><br/>
 and<br/>
 <em>{if $use_thumbnails eq true && $pagename eq "story" && $url_short neq "http://" && $url_short neq "://"}&lt;b&gt;&lt;img src="http://images.websnapr.com/?url={$url_short}&size=T" style="float:right; padding-left:10px;padding-top:35px;">&lt;/b&gt;{/if}</em><br/><br/>
 
 To comment out and keep for later, simply change it to:<br/><br/>
 
 <em>&lt;!-- {if $Enable_Extra_Field_1 eq 1}{if $link_field1 neq ""}&lt;br/&gt;&lt;b&gt;{$Field_1_Title}:&lt;/b&gt; {$link_field1}{/if}{/if}&lt;br/&gt;&lt;br/&gt; //--&gt;</em><br/>
 and<br/>
 <em>&lt;!-- {if $use_thumbnails eq true && $pagename eq "story" && $url_short neq "http://" && $url_short neq "://"}&lt;b&gt;&lt;img src="http://images.websnapr.com/?url={$url_short}&size=T" style="float:right; padding-left:10px;padding-top:35px;">&lt;/b&gt;{/if} //--&gt;</em><br/><br/>
 
 </li>

<h3>Module Configuration</h3>

All admin settings are changed in this file.  Modifying these settings can be trial and error to fit the design of your site.<br/><br/>

<li>Edit <b>/modules/image_upload/image_upload_settings.php</b><br/><br/>

<table border="1" cellpadding="0" cellspacing="0" width="100%">
	<tbody>
		<tr>
			<td valign="top">
				Module Setting
			</td>
			<td valign="top">
				Default Setting
			</td>
			<td valign="top">
				Options
			</td>
			<td valign="top">
				Usage
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_basedir
			</td>
			<td valign="top" class="default">
				$_SERVER['DOCUMENT_ROOT'].$mypliggbase
			</td>
			<td valign="top" class="default">
				
			</td>
			<td valign="top" class="usage">
				Used to know where Pligg's installed at.  It's a little hack as thumb.php uses part of it.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_imagedir
			</td>
			<td valign="top" class="default">
				images/
			</td>
			<td valign="top" class="default">
			</td>
			<td valign="top" class="usage">
				The path from your Pligg installation to an images folder within your Pligg directory -- must include the trailing slash.  If Pligg is installed in your WWW root, then this should be changed to <b>images/</b>.  This directory must be writable so chmod it to 755 or 644.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_gdversion
			</td>
			<td valign="top" class="default">
				2
			</td>
			<td valign="top" class="default">
				1 or 2
			</td>
			<td valign="top" class="usage">
				To create thumbnails, GD support needs to be enabled in PHP.  Most PHP installations has GD 2.x installed.  If your host only has GD 1.x installed, change this to <b>1</b>.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_jpg_quality
			</td>
			<td valign="top" class="default">
				80
			</td>
			<td valign="top" class="default">
				1-100
			</td>
			<td valign="top" class="usage">
				By default, all images larger than the fullsize width / height you indicate will be resized.  All GIF, PNG and WBMP images will be converted to JPG format.  In either case, this sets the JPG quality of the final image.  Higher numbers = less compression and larger file size.  Lower numbers = more compression and smaller file size.  The more compression, the more artifacts will be visible in the image.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_use_thickbox
			</td>
			<td valign="top" class="default">
				true
			</td>
			<td valign="top" class="default">
				true / false
			</td>
			<td valign="top" class="usage">
				If set to true, Image Upload will attempt to use Thickbox module to overlay image in a "lightbox" effect.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_use_thumb
			</td>
			<td valign="top" class="default">
				true
			</td>
			<td valign="top" class="default">
				true / false
			</td>
			<td valign="top" class="usage">
				If set to true, module will show a thumbnail.  If false, the fullsize image will be shown.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_thumb_width
			</td>
			<td valign="top" class="default">
				150
			</td>
			<td valign="top" class="default">
				
			</td>
			<td valign="top" class="usage">
				This is the maximum width the thumbnail should be.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_thumb_height
			</td>
			<td valign="top" class="default">
				150
			</td>
			<td valign="top" class="default">
				
			</td>
			<td valign="top" class="usage">
				This is the maximum height the thumbnail should be.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_thumb_square
			</td>
			<td valign="top" class="default">
				true
			</td>
			<td valign="top" class="default">
				true / false
			</td>
			<td valign="top" class="usage">
				If set to true, the thumbnail will be the width x height set for thumbnails with as little scaling as possible.  Thumbnail will be cropped.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_thumb_prefix
			</td>
			<td valign="top" class="default">
				th_
			</td>
			<td valign="top" class="default">
				
			</td>
			<td valign="top" class="usage">
				(future use)
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_fullsize_maxtoggle
			</td>
			<td valign="top" class="default">
				w
			</td>
			<td valign="top" class="default">
				w / h
			</td>
			<td valign="top" class="usage">
				If thumbnails are scaled and module_imageupload_thumb_square is false, then this allows you to set the maximum width or maximum height of the thumbnail.  As images are rarely square, this will force the thumbnail routine to be sure it adheres to one dimension.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_fullsize_width
			</td>
			<td valign="top" class="default">
				500
			</td>
			<td valign="top" class="default">
				
			</td>
			<td valign="top" class="usage">
				Maximum width any uploaded images should be.  Any image wider than this value is scaled in proportion to the maximum height (below).
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_fullsize_height
			</td>
			<td valign="top" class="default">
				500
			</td>
			<td valign="top" class="default">
				
			</td>
			<td valign="top" class="usage">
				Maximum height any uploaded pictures should be.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_filename_field
			</td>
			<td valign="top" class="default">
				link_field1
			</td>
			<td valign="top" class="default">
				
			</td>
			<td valign="top" class="usage">
				Very important.  As Extra Fields need to be enabled in the Admin, indicating the link_field you are using will allow the module to update the database with the correct image filename when completed.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_debugmode
			</td>
			<td valign="top" class="default">
				false
			</td>
			<td valign="top" class="default">
				true / false
			</td>
			<td valign="top" class="usage">
				Turning on debug mode will output messages from the module about what its currently doing and information about the file being processed.  This should be turned off in a production environment.
			</td>
		</tr>
		<tr>
			<td valign="top" class="name">
				module_imageupload_legendtext
			</td>
			<td valign="top" class="default">
				(HTML Code)
			</td>
			<td valign="top" class="default">
				
			</td>
			<td valign="top" class="usage">
				This is the legend text that appears below a thumbnail to inform the user to clic the image for  larger version.  This can contain properly formatted and escaped HTML code.
			</td>
		</tr>
	</tbody>
</table>

There are additional settings, however, for most people they will not have to adjust them.  Changing them may cause issues.
</ol>

<h3>Revision History</h3>
v0.4 2007/04/12 Cent - Fixed image conversion process.<br/>
v0.3 2007/04/11 Cent - Added code for square thumbnails.  Improved documentation readability.<br/>
v0.2 2007/04/10 Cent - Fixed code and stability issues<br/>
v0.1 2007/04/08 Cent - First version